package com.gkj.blog.business.enums;

public enum SexEnum {
    WOMAN((byte)0,"女"),MAN((byte)1,"男");
    private Byte code;
    private String sex;
    SexEnum(Byte code,String sex){
        this.code=code;
        this.sex=sex;
    }
    public static SexEnum get(Byte code){
        if(code==null)
            return null;
        SexEnum[] vals=SexEnum.values();
        for(SexEnum s:vals){
            if(s.getCode()==code){
                return s;
            }
        }
        return SexEnum.MAN;
    }
    public static SexEnum getBySex(String sex){
        SexEnum[] vals=SexEnum.values();
        for(SexEnum s:vals){
            if(s.getSex().equals(sex)){
                return s;
            }
        }
        return SexEnum.MAN;
    }
    public Byte getCode(){
        return code;
    }
    public String getSex(){
        return sex;
    }
}
